//
//  HYAppMsgModuleManager.m
//  HYApp
//
//  Created by victor lau on 2018/11/28.
//  Copyright © 2018年 Unidax. All rights reserved.
//

#import "HYAppMsgModuleManager.h"

@implementation HYAppMsgModuleManager


+ (instancetype)sharedInstance {
    static HYAppMsgModuleManager *_sharedClient = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedClient = [[HYAppMsgModuleManager alloc] init];
    });
    return _sharedClient;
}
-(instancetype)init{
    self = [super init];
    if (self) {
        
    }
    return self;
}

//同步方法
- (JFMsgCenterVo*)syncFunctionForward:(JFMsgCenterVo*)vo{
    
    JFMsgCenterVo * msgCenter = [[JFMsgCenterVo alloc] init];
    msgCenter.requestNum = vo.requestNum;
    msgCenter.params = vo.params;
    //调用插件
    msgCenter = [JFMsgCenteManager requestWithMsgCenterVo:msgCenter callback:^(JFResultVo *resultVo) {
        
    }];
    msgCenter.from = vo.to;
    msgCenter.to = vo.from;
    return msgCenter;
}

//异步方法
- (void)asyncFunctionForward:(JFMsgCenterVo*)vo{
    
    if(vo.to){
        JFMsgCenterVo * msgCenter = [[JFMsgCenterVo alloc] init];
        msgCenter.requestNum = vo.requestNum;
        msgCenter.params = vo.params;
        msgCenter.callback = ^(JFResultVo *resultVo) {
            JFMsgCenterVo * msg = [[JFMsgCenterVo alloc] init];
            if(vo.respodNum){
                msg.params = resultVo.results;
                msg.requestNum = vo.respodNum;
                msg.from = vo.to;
                msg.to = vo.from;
                [JFMsgCenteManager requestWithMsgCenterVo:msg callback:^(JFResultVo *resultVo) {
                    
                }];
            }else{
                if(vo.callback){
                    vo.callback(resultVo);
                }
            }
        };
        //调用插件
        [JFMsgCenteManager requestWithMsgCenterVo:msgCenter callback:^(JFResultVo *resultVo) {
            
        }];
    }else{  //广播
        
    }
    
}

@end
